﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace Web1
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string strCn = "server=pc.hstc.cn;database=dhd2014112121;uid=2014112121;pwd=19940809";
            if (txtName.Text == "")
            {
                Response.Write("<script>alert('用户名不能为空！')</script>");
                txtName.Focus();
            }
            else
                if (txtPwd.Text == "")
                {
                    Response.Write("<script>alert('密码不能为空！')</script>");
                    txtPwd.Focus();
                }
            string strSQL = "select * from [User] where Name='" + txtName.Text + "'  AND Pwd='" + txtPwd.Text + "'";
            SqlConnection conn = new SqlConnection(strCn);
            conn.Open();
            DataSet ds = new DataSet();
            SqlDataAdapter sql = new SqlDataAdapter(strSQL, conn);
            sql.Fill(ds);
            conn.Close();
            if (ds.Tables[0].Rows.Count > 0)
            {
                Response.Redirect("WebForm9.aspx" );
             

            }
            else
            {
                Response.Write("<script>alert('用户名或密码错误')</script>");
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {

        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            this.txtName.Text = "";
            this.txtPwd.Text = "";
        }
        }
    }
